const util = require('../utils/util.js')
const wxRequest = require('../utils/wx-request.js')
const url = require('../utils/api-config.js')






module.exports = {
  //登录，获取token
   requestPostLanderToken : function (wx_login_code, wx_user_info, code200) {
    let data = {
      wx_login_code: wx_login_code,
      wx_user_info: wx_user_info
    }
    wxRequest.POST(url.post_lander_token, data, code200)
  },


// 房源
 requestToAddHouse : function (area, house_name, code200) {
    let data = {
      area: area,
      house_name: house_name
    }
    wxRequest.POST(url.houses, data, code200)
  },

 requestToGetHouse: function (code200) {
   let data = {

   }
   wxRequest.GET(url.houses, data, code200)
 },


//  账本
 requestToAddBook: function (book, code200) {
  //  house_id, renter_phone, renter_name, rent_begin_date, rent_month_count, pay_in_day, pay_month_count, money_secure, money_per_month
   let data = {
     house_id: book.house_id,
     renter_phone: book.renter_phone,
     renter_name: book.renter_name,
     rent_begin_date: book.rent_begin_date,
     rent_month_count: book.rent_month_count,
     pay_in_day: book.pay_in_day,
     pay_month_count: book.pay_month_count,
     money_secure: book.money_secure,
     money_per_month: book.money_per_month,
   }
   wxRequest.POST(url.houses_books, data, code200)
 },

 requestToGetHouseBook: function (code200) {
   let data = {

   }
   wxRequest.GET(url.houses_books, data, code200)
 },

 requestPostRenterToken: function (wx_login_code, wx_user_info, code200) {
   let data = {
     wx_login_code: wx_login_code,
     wx_user_info: wx_user_info
   }
   wxRequest.POST(url.post_renter_token, data, code200)
 },


 requestPutRenterPhone: function (phone, code, code200) {
   let data = {
     phone: phone,
     code: code
   }
   wxRequest.PUT(url.put_renter_phone, data, code200)
 },
// 查看手机关联的账本
 requestToGetBook: function (type,code200) {
   let data = {
     type: type||""
   }
   wxRequest.GET(url.to_renter_books, data, code200)
 },
//  绑定房源
 requestPutBookPhone: function (book_ids, code200) {
   let data = {
     book_ids: book_ids,
   }
   wxRequest.PUT(url.to_renter_books, data, code200)
 },


 //  
 requestToGetBill: function (book_id,trade_state,code200) {
   let data = {
     book_id: book_id, 
     trade_state: trade_state
   }
   wxRequest.GET(url.to_bills, data, code200)
 },

 requestToGetWxPayData: function (bill_id,code200) {
    let data = {
      bill_id: bill_id
    }
    wxRequest.GET(url.wx_pay_data, data, code200)
  },

  requestToGetBillDetail: function (bill_id, code200,error) {
   let data = {
   }
   wxRequest.GET(url.to_bills + "/" + bill_id, data, code200, error)
 },

 
  requestToPostBindPhoneSmsCode: function (phone, code200) {
    //  house_id, renter_phone, renter_name, rent_begin_date, rent_month_count, pay_in_day, pay_month_count, money_secure, money_per_month
    let data = {
      type: "RENTER_BIND_PHONE",
      phone: phone,
    }
    wxRequest.POST(url.to_post_sms_code, data, code200)
  },
}